var utils={};
utils.html={
	data:{},
	switchView:function(obj,view){
		var display=obj.style.display;
		if(!view){
			if(display=='none') display='';
			else display='none';
		}
		else{
			if(view) display='';
			else display='none';
		}
	},
	changeCls:function(obj,cls){
		if(obj.className!=''&&!obj._className){
			obj._className=obj.className;
		}
		if(cls) obj.className=cls;
		else if(obj._className) obj.className=obj._className;
	},
	swapImages:function(save){
		var arr=arguments;
		for(var i=1;i<arr.length;i=i+2){
			var obj=$(arr[i]);
			if(obj){
				if(save==1)obj._src=obj.src;
				obj.src=arr[i+1];
				if(save==2)obj._src=obj.src;
			}
		}
	},
	restoreImages:function(){
		var arr=arguments;
		for(var i=1;i<arr.length;i++){
			var obj=$(arr[i]);
			if(obj) obj.src=obj._src;
		}
	},
	changeStyle:function(obj,name,value){
		var name2='_'+name;
		if(obj.style[name]!=''&&!obj.style[name2]){
			obj.style[name2]=obj.style[name];
		}
		if(name){
			if(value) obj.style[name]=value;
			else if(obj.style[name2]) obj.style[name]=obj.style[name2];
		}
	},
	trim:function(str){
		return str.replace(/^[\s　]*|[\s　]*$/,'');
	},
	isInputText:function(obj){
		var name='value';
		var name2='_value';
		if(!obj[name2]) return false;
		else if(this.trim(obj[name])==obj[name2]) return false;
		return true;
	},
	cleanText:function(obj,state){
		var name='value';
		var name2='_value';
		if(state==1){
			if(!obj[name2]) obj[name2]=obj[name];
			if(obj[name]==obj[name2]) obj[name]='';
		}
		else if(state==0){
			if(this.trim(obj[name])=='') obj[name]=obj[name2];
		}
	},
	isEmpty:function(str){
		var re=/\S+/;
		if(re.test(str)) return false;
		else return true;
	},
	preloadImages:function (){
		var d=document;
		var data=this.data;
		if(d.images){
			if(!data.preImgList) data.preImgList=new Array();
			var j=data.preImgList.length;
			var preImgList=data.preImgList;
			for(var i=0;i<arguments.length;i++){
				preImgList[j]=new Image();
				preImgList[j++].src=arguments[i];
			}
		}
	},
	adjustPos:function(){
	}
}

Object.extend = function(dest, source, replace) {
	for(prop in source) {
		if(replace == false && dest[prop] != null) continue;
		dest[prop] = source[prop];
	}
	return dest;
};


Object.extend(window, {
	$: function() {
		var elements = new Array();
		for(var i=0; i<arguments.length; i++) {
			var e = arguments[i];
			if(typeof e == 'string')
				e = document.getElementById(e);
			if (arguments.length == 1)
				return e;
			elements.push(e);
		}
		return elements;
	},
	Class: {
		create: function() {
			return function() {
				if(typeof this.initialize == "function")
					this.initialize.apply(this, arguments);
			}
		}
	}
}, false);